﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace LibraryMIS
{
    public partial class mainform : Form
    {
        int pane1Width=130;
        bool isCollspased;  
        public mainform()
        {
            InitializeComponent();
            isCollspased = false;
            timer2.Start();
        }

        private void mainform_Load(object sender, EventArgs e)
        {

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            timer1.Start();
        }

        private void pictureBoxLOGO_Click(object sender, EventArgs e)
        {

        }

        private void label2_Click(object sender, EventArgs e)
        {

        }

        private void pictureBoxclose_MouseEnter(object sender, EventArgs e)
        {
            pictureBoxclose.BackColor = Color.Red;
            //this.Close();
            //this.Dispose();

        }

        private void pictureBoxclose_MouseLeave(object sender, EventArgs e)
        {
            pictureBoxclose.BackColor = Color.White;
        }
        private void pictureBoxclose_Click(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            MovePanel(button6);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            MovePanel(button7);
        }

        private void label4_Click(object sender, EventArgs e)
        {

        }

        private void btn8_Click(object sender, EventArgs e)
        {
            MovePanel(btn8);
            Aboutus us = new Aboutus();
            us.ShowDialog();
        }

        private void panelLeft_Paint(object sender, PaintEventArgs e)
        {

        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (isCollspased)
            {
                panelLeft.Width = panelLeft.Width + 10;
                if (panelLeft.Width >= pane1Width)
                {
                    timer1.Stop();
                    isCollspased = false;
                    this.Refresh();
                }
            }
            else
            {
                panelLeft.Width = panelLeft.Width - 10;
                if(panelLeft.Width <= 59)
                {
                    timer1.Stop();
                    isCollspased = true;
                    this.Refresh();
                }
            }
        }

        private void pictureBoxclose_Click_1(object sender, EventArgs e)
        {
            System.Environment.Exit(0);
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            DateTime timer2 = DateTime.Now;
            label5.Text = timer2.ToString("HH;MM;ss");
        }
        #region Panel的光标移动（panel);
        private void MovePanel(Control controName)
        {
            panel.Top = controName.Top;
            panel.Height = controName.Height;
        }
        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            MovePanel(button1);
            

        }

        private void button5_Click(object sender, EventArgs e)
        {
            MovePanel(button5);
            //UserControl1 mb = new UserControl1();
            //AddContainerToPanel(mb);
        }

        private void btnBoorrowsbook_Click(object sender, EventArgs e)
        {
            MovePanel(btnBoorrowsbook);
        }

        private void button3_Click(object sender, EventArgs e)
        {
            MovePanel(button3);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            MovePanel(button2);
        }
        private void AddContainerToPanel(Control controlName)
        {
            controlName.Dock = DockStyle.Fill;
            panelModelContent.Controls.Clear();
            panelModelContent.Controls.Add(controlName);

        }

        private void panelModelContent_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
